#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, m, n;
  int box = 0;
  cin >> a >> b >> m >> n;
  if (a >= m) {
    cout << a;
    return 0;
  }
  if (b >= m) {
    cout << a + b;
    return 0;
  }
  box = a + b;
  for (int i = 3; i <= n; i++) {
    int x = a + b;
    box = box + x;
    if (x >= m) {
      break;
    }
    a = b;
    b = x;
  }
  cout << box;
  return 0;
}